<!DOCTYPE html>
<html lang="en">
<html>
<head>
    <meta charset="UTF-8">
    <title>新增地址</title>
    <link rel="stylesheet" href="/js/bootstrap.min.css">
    <script src="/js/jquery-3.2.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(function () {
            getParam();

            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null)
                    return unescape(r[2]);
                return null; //返回参数值
            }

            function getParam() {
                var userid = getUrlParam("userid");
                $("#userid").attr("value", userid);
            };

            $("#button").click(function () {
                //保存信息
                var newAddress = $("#addForm form")[0];
                var formaDate = new FormData(newAddress);
                $.ajax({
                    url: "/applets/address/add",
                    type: "post",
                    data: formaDate,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function (data) {
                        alert(data.msg);
                    }
                });
            });
        });
    </script>
</head>
<body>
<div class="container" id="addForm">
    <h2 class="text-center">新增地址</h2>

    <!--导航-->
    <ul class="nav nav-tabs">
        <li class="nav-item">
            <a class="nav-link active" href="ShowAddress.html">返回展示界面</a>
        </li>
    </ul>

    <form action="#" method="post">
        <div class="form-group">
            <label>用户号</label>
            <input type="number" name="userid" class="form-control" id="userid" readonly>
        </div>
        <div class="form-group">
            <label>标签</label>
            <input type="text" name="tag" class="form-control">
        </div>
        <div class="form-group">
            <label>地址</label>
            <input type="text" name="addr" class="form-control">
        </div>
        <div class="form-group">
            <label>手机号</label>
            <input type="number" name="telephone" class="form-control">
        </div>
        <div class="form-group">
            <label>收件人</label>
            <input type="text" name="receivename" class="form-control">
        </div>
        <div class="form-group">
            <input type="button" id="button" class="form-control" value="提交">
        </div>
    </form>
</div>
</body>
</html>